<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('种植作物明细管理')" />
</head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="analysis-tsl-form">
                <div class="select-list">
                    <ul>
                        <li class="select-time">
                            <label>选择月份： </label>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-warning" onclick="$.table.exportExcel()" >
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped" style="width:100%" >
            <table id="bootstrap-table" ></table>
        </div>

    </div>
</div>
</div>

<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('cropmanage:crop_edit')}]];
    var removeFlag = [[${@permission.hasPermi('crop:remove')}]];
    var crop_type = [[${@dict.getType('crop_type')}]];
    var crop_year = [[${@dict.getType('crop_year')}]];
    var prefix = ctx + "cropmanage";
    $(function() {
        var options = {
            url:prefix+ "/detaillist",
            exportUrl: prefix + "/export",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            sortName: "id",
            sortOrder: "asc",
            modalName: "作物明细",
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            columns: [
                {
                    field: 'cropId',
                    title: '序号'
                },
                {
                    field: 'cityName',
                    title: '县区',
                    sortable: true
                },
                {
                    field: 'townName',
                    title: '林业局、农场',
                    sortable: true
                },
                {
                    field: 'custName',
                    title: '农户、合作社',
                    sortable: true
                },
                {
                    field: 'address',
                    title: '详细地址',
                    sortable: true
                },
                {
                    field: 'linkPhone',
                    title: '联系电话',
                    sortable: true
                },
                {
                    field: 'cropName',
                    title: '作物名称',
                    sortable: true
                },
                {
                    field: 'mianji',
                    title: '种植面积'
                },
                {
                    field: 'sort1',
                    title: '作物分类',
                    formatter: function(value, item, index) {
                        return $.table.selectDictLabel(crop_type, item.sort1);
                    }
                },
                {
                    field: 'sort2',
                    title: '生长周期',
                    formatter: function(value, item, index) {
                        return $.table.selectDictLabel(crop_year, item.sort2);
                    }
                },
                {
                    field: 'lng',
                    title: '经度',
                    sortable: true
                },
                {
                    field: 'lat',
                    title: '经度',
                    sortable: true
                },
                {
                    field: 'status',
                    title: '状态',
                    sortable: true,
                    formatter: function(value, row, index) {
                        if (value == 0) {
                            return '<span class="badge badge-primary">正常</span>';
                        } else {
                            return '<span class="badge badge-danger">失效</span>';
                        }
                    }

                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.cropId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.cropId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

</script>
</body>
</html>